package com.sdtele.tta.operation;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.sdtele.tta.dac.Dac;
import com.sdtele.tta.models.JsonRequest;
import com.sdtele.tta.models.JsonResponse;
import com.sdtele.tta.models.Team;
import com.sdtele.tta.models.User;
import com.sdtele.tta.utils.TeamUtils;

/**
 * 操作类实现：GetUser(json.operation=getUser)
 * @author XCream
 */
public class OperationGetContacts extends Operation {

	@Override
	public JsonResponse handle(JsonRequest jsonRequest) {				
		JsonResponse jres = new JsonResponse();
		User curUser = (User) request.getSession().getAttribute("user");
		if (curUser != null) {
			Map<String, Long> tMap = new HashMap<String, Long>();
			TeamUtils.findRootTeamId(curUser.getTeamId(), tMap);
			long rootTeamId=tMap.get("teamId");
			Map<String, Object> teamMap = new HashMap<String, Object>();
			teamMap=TeamUtils.TeamToMap(Dac.getInstance().getTeam(rootTeamId));
			TeamUtils.fillContextBook(teamMap);
			jres.setStatus(0);
			jres.setMessage("");
			jres.setEntity(teamMap);
		}else {
			jres.setStatus(1);
			jres.setMessage("用户未登录");
		}		
		return jres;		
	}

	
	
}
